<template>
	<view class="page_box">		
		<view class="content_box">
			<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
				<checkbox-group @change="onSel" v-if="customerList.length">
					<view class="collect-list x-f" v-for="f in customerList" :key="f.id">
						<view class="y-start">
							<view class="goods-title more-t">{{ f.CustomerName }}</view>
							<view class="goods-title more-contact">{{ f.ContactName }}</view>
							<view class="price">{{ f.ContactPhone }}</view>
							<view class="button">
								<text class="iconfont icon-school" @click="jump('/pages/app/dealer/index',{title:f.CustomerPageTitle,name:'',code:f.id})">进入</text>
								<text class="iconfont icon-buoumaotubiao06" @click="jump('/pages/app/dealer/myCustomerSetting',{code:f.id})">设置</text>
								<text class="iconfont icon-fenxiang" @click="share(f)">分享</text>
							</view>
						</view>
					</view>
				</checkbox-group>
				<!-- 缺省页 -->
				<shopro-empty v-if="!customerList.length" :emptyData="emptyData"></shopro-empty>
				<!-- 更多 -->
				<!-- <view v-if="customerList.length" class="cu-load text-gray" :class="loadStatus"></view> -->
			</scroll-view>
			<view v-if="showShare" class="shareProp">
				<view class="sharePropBox">
					<view style="display:inline-block;">复制下方链接，并分享：</view>
					<view class="shareContent">
						<view class="item">链接:</view>
						<view class="item"><input :value="showShareUrl" style="font-size:24rpx;padding:0rpx 10rpx;line-height:50rpx;height:50rpx;"/></view>
						<view class="item" @click="onCopy">复制</view>
					</view>
					<view style="display:inline-block;margin-top:5px;text-align: center;width: 100%;margin-top:10px;">
						<button size="mini" @click="showShare=false">关闭</button>
					</view>
				</view>
			</view>
		</view>		
		<!-- 自定义底部导航 -->
		<!-- <shopro-tabbar></shopro-tabbar> -->
		<!-- 关注弹窗 -->
		<!-- <shopro-float-btn></shopro-float-btn> -->
		<!-- 连续弹窗提醒 -->
		<!-- <shopro-notice-modal></shopro-notice-modal> -->
		<!-- 登录提示 -->
		<!-- <shopro-login-modal></shopro-login-modal> -->
	</view>
</template>

<script>
import shoproMiniCard from '@/components/shopro-mini-card/shopro-mini-card.vue';
import shoproEmpty from '@/components/shopro-empty/shopro-empty.vue';
export default {
	components: {
		shoproMiniCard,
		shoproEmpty
	},
	data() {
		return {
			isSel: false,
			allSel: false,
			routerTo: this.$Router,
			selList: [],
			emptyData: {
				img: '/static/imgs/empty/empty_goods.png',
				tip: '暂无企业信息'
			},
			customerList: [],
			total: 0,
			loadStatus: '', //loading,over
			currentPage: 1,
			lastPage: 1,
			showShare:false,
			showShareUrl:"",
		};
	},
	computed: {},
	onShow() {
		this.init();
	},
	onHide() {
		this.dealerList = [];
	},
	methods: {
		// init
		init() {
			// return Promise.all([this.getFavoriteList()]);
			let that=this;
			let loadDistributeConfig=function(){
				uni.request({
					url: that.$config.API_URL+"DistributeShop/list",
					method:"POST",
					data:{
						shopid:uni.getStorageSync("storeid")
					},
					success: (result) => {			
						console.log(result.data);
						that.customerList=result.data;
					},
					fail:(error)=>{
						console.log("身份服务错误");
					}
				})
			}
			loadDistributeConfig()
		},	
		// 路由跳转
		jump(path, parmas) {
			this.$Router.push({
				path: path,
				query: parmas
			});
		},
		share(f){
			this.showShare=true;
			let url='/pages/app/dealer/index';
			this.showShareUrl=window.location.href.replace("/pages/app/dealer/myCustomer",url)+"?code="+f.id;
		},
		onCopy() {
			let that = this;
			uni.setClipboardData({
				data: this.showShareUrl,
				success: function(data) {
					//#ifdef H5
					that.$tools.toast('已复制到剪切板');
					//#endif
				},
				fail: function(err) {},
				complete: function(res) {}
			});
		},
	}
};
</script>

<style lang="scss">
// @import url('//at.alicdn.com/t/font_956911_py2eooakww9.css');

.head_box {
	height: 70rpx;
	padding: 0 30rpx;

	.count-box {
		font-size: 26rpx;
		color: #999;

		.all-num {
			color: #a8700d;
		}
	}

	.set-btn {
		background: none;
		font-size: 26rpx;
		color: #a8700d;
	}
}

.collect-list {
	padding: 30rpx 20rpx;
	background: #fff;
	margin-bottom: 20rpx;

	.goods-radio {
		transform: scale(0.7);
		margin-right: 20rpx;
	}
	
	.y-start{
		display:flex;
		flex-direction:row;
		flex-wrap:wrap;
		width:100%;
		
		.goods-title{
			display:inline-block;
			width:60%;
			font-size:16px;
			flex-grow:1;
			flex-shrink:1;
		}
		.sub-tip{
			display:inline-block;
			font-size:14px;
			flex-grow:0;
			flex-shrink:0;
			
		}
		.price{
			display:block;
			margin-top:5px;
			font-size:14px;
			color:#FE7C0F;
			width:100%;
		}
		.more-contact{
			margin-top:5px;
			font-size:28rpx;
		}
		.button{
			text-align:right;
			margin-top:20rpx;
			
			text{
				display:inline-block;
				margin-right:20rpx;
				font-size:28rpx;
				
				&:before{
					font-size:32rpx;
					margin-right:10rpx;
				}
			}
		}
	}
}

.tools-box {
	height: 100rpx;
	width: 750rpx;
	padding: 0 20rpx;
	background: #fff;

	.check-all {
		font-size: 26rpx;

		.check-all-radio {
			transform: scale(0.7);
		}
	}

	.close-btn {
		width: 200rpx;
		height: 70rpx;
		background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
		box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
		border-radius: 35rpx;
		padding: 0;
		color: rgba(#fff, 0.9);
	}
}

.shareProp{
	position:fixed;
	top:0px;
	bottom:0px;
	left:0px;
	right:0px;
	display:flex;
	align-items:center;
	justify-content:center;
	
	.sharePropBox{
		display:inline-block;
		width:80%;
		// height:200rpx;
		
		padding:30rpx;
		line-height:40rpx;
		font-size:28rpx;
		
		background-color:white;
		border:solid 1px #cccccc;
		
		.shareContent{
			margin-top:10rpx;
			 display:flex;
			 justify-content:space-between;
			.item:nth-of-type(1){
				height:50rpx;
				line-height:50rpx;
				width:80rpx;
				flex-grow:0;
				flex-shrink:0;
				font-size:28rpx;
				
				text-align:left;
				// background-color:#cccccc;
			}
			.item:nth-of-type(2){
				height:50rpx;
				line-height:50rpx;
				flex-grow:1;
				font-size:28rpx;
				background-color:#efefef;
			}
			.item:nth-of-type(3){
				height:50rpx;
				line-height:50rpx;
				width:80rpx;
				flex-grow:0;
				flex-shrink:0;
				font-size:28rpx;
				text-align:center;
				background-color:#cccccc;
			}
			.item:nth-of-type(4){
				
			}
			
		}
	}
}

</style>
